package com.ton.common.service;

import com.kypj.frame.db.MyTemplate;
import com.ton.common.entity.CollectionRecord;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
public class CollectionRecordService {

    @Autowired
    private MyTemplate myTemplate;

    /**
     * 新增一条归集记录
     */
    public void insertCollectionRecord(CollectionRecord collectionRecord){
         myTemplate.mySaveObject(collectionRecord);
    }


    /**
     * 批量新增归集记录
     */
    public void batchSaveCollectionRecord(List<CollectionRecord> list){
        myTemplate.mySaveObject(list);

    }

    /**
     * 更新资金归集表内容
     * @param collectionRecord 资金归集对象
     */
    public void updateCollectionRecord(CollectionRecord collectionRecord){
        myTemplate.myUpdateObject(collectionRecord);
    }


    /**
     * 批量删除
     * @param ids ids
     */
    @Transactional
    public void batchDelete(String ids){
        String[] split = ids.trim().split(",");
        for (int i = 0; i < split.length; i++) {
            myTemplate.myDeleteObjectByPK(CollectionRecord.class,split[i]);
        }
    }
}
